<?php

namespace app\modules\adminapi\controllers;

use app\helpers\Upload;
use yii\rest\Controller;

class PictureController extends Controller
{
    public function actionUpload()
    {
        $pic_data = \Yii::$app->request->post('pic_data');
        $pic_url = Upload::uploadtofile(base64_decode(preg_replace('/^(data:\s*image\/(\w+);base64,)/', '', $pic_data)));
        return [
            'pic_url'=>$pic_url
        ];
    }
}
